![]() |
Kinetis SDK Demo Applications User Guide
1.0.0-beta
Freescale Semiconductor, Inc. Confidential - NDA only
|
DSPI eDMA Demo program needs the following hardware:
The following will appear in the terminal window:
DSPI Transfers using eDMA
| Setting | Value |
|---|---|
| Terminal Baud: | 115200 bps |
| TDSPI Bit rate: | 5000 bps |
| TDSPI Master: | DSPI0 |
| TDSPI Slave: | DSPI1 |
| Master | Slave |
|---|---|
| SS PTD0 | PTB10 |
| SCK PTD1 | PTB11 |
| MstOut PTD2 | PTB17 SlvIn |
| MstIn PTD3 | PTB16 SlvOut |
| Master | Slave |
|---|---|
| SS PTD0 | PTD4 |
| SCK PTD1 | PTD5 |
| MstOut PTD2 | PTD7 SlvIn |
| MstIn PTD3 | PTD6 SlvOut |
This indicates the speed of the SPI transfers, and what pins to connect and how to connect them.
void dspi_edma_master_setup(uint8_t instance, uint32_t baudRateHz, uint8_t transferSizeBits)
Takes in the DSPI module instance, the desired data rate of DSPI transfers, and the frame size of the data transfer. Initializes master instance of DSPI.
| instance | DSPI module instance |
| baudRateHz | Pass in the desired baud rate of DSPI transfers in Hz. |
| transferSizeBits | Pass data frame size (8 or 16 bit) |
void dspi_edma_slave_setup(uint8_t instance, uint8_t transferSizeBits)
Takes in the DSPI module instance, and the frame size of the data transfer. Initializes slave instance of DSPI.
| instance | DSPI module instance |
| transferSizeBits | Pass data frame size (8 or 16 bit) |
dspi_status_t data_source(uint8_t * sourceWord, uint32_t instance)
Callback function for DSPI slave. Used to transmit data from slave. In this application it generates slave data out, the data out is a count.
| sourceWord | 8-bit data variable to be passed to slave PUSHR register. |
| instance | Instance of the DSPI module. |
void on_error(dspi_status_t error, uint32_t instance)
Callback function for DSPI slave. Used to handle errors. In this application is sets the error flag to signal the end of the demonstration.
| error | Uses dspi_status_t value given by driver interrupt handler. |
| instance | Instance of the DSPI module. |
void setup_edma_loop(edma_loop_setup_t *loopSetup, uart_state_t *uart)
Configures an eDMA transfer loop using a loopSetup structure, and if a valid uart_state_t is passed will print out the TCD for that loop.
| loopSetup | Data structure defined by user, containing all the parameters for the eDMA loop. |
| uart | Pointer to a valid uart_state_t for debug printing. |
void disable_edma_loop(edma_loop_setup_t *loopSetup, uart_state_t *uart)
Disables user configured eDMA transfer loop. Also, will free memory allocated by eDMA transfer loop. If a valid uart_state_t is passed will print out the TCD for that loop.
| loopSetup | Data structure defined by user, containing all the parameters for the eDMA loop. |
| uart | Pointer to a valid uart_state_t for debug printing. |
void *mem_align(size_t ptrSize, uint32_t alignment)
Function to peform aligned data memory allocation. Useful when memalign is not available.
| ptrSize | size_t variable to pass size of memory to be allocated |
| alignment | uint32_t variable to pass byte size to align data with |
Function to free memory allocated by mem_align
| ptr | pointer that has been allocated with mem_align |